package cn.com.twoke.easyproject.common.response;

public class R {

    public static <T> Result<T> success(T data) {
        return valueOf(data, ResponseCode.OK);
    }

    public static <T> Result<T> success() {
        return success(null);
    }

    public static <T> Result<T> valueOf(T data, String message, String tips, Integer code) {
        return Result.<T>builder()
                .code(code)
                .data(data)
                .message(message)
                .tips(tips)
                .build();
    }

    public static <T> Result<T> valueOf(T data, ResponseCode responseCode, String tips) {
        return valueOf(data, responseCode.message, tips, responseCode.code);
    }

    public static <T> Result<T> valueOf(T data, ResponseCode responseCode) {
        return valueOf(data, responseCode.message, null, responseCode.code);
    }

}
